<template>
  <div class="carousel-container">
    <div class="carousel-list">
      <div class="carousel-item">1</div>
      <div class="carousel-item">2</div>
      <div class="carousel-item">3</div>
    </div>
    <div class="carousel-prev"><</div>
    <div class="carousel-next">></div>
    <div class="indicator">
      <span class="active"></span>
      <span></span>
      <span></span>
    </div>
  </div>
</template>

<script setup lang="ts">
const imgs = ref<number[]>([]);
function init() {
  imgs.value = Array.from({ length: 3 }, (_, i) => i);
}

init();
</script>

<style lang="scss" scoped>
.carousel-container {
  // position: absolute;
  // left: 50%;
  // right: 50%;
  // transform: translate(-50%,0 5%);
  // overflow: hidden;
  position: relative;
  .carousel-list {
    width: 200px;
    height: 100px;
    display: flex;
    border: 2px solid #000;
    .carousel-item {
      width: 200px;
      height: 100px;
      line-height: 100px;
      color: #000;
      flex: 0 0 100%;
      z-index: -1;
    }
    & > :nth-child(1) {
      background-color: #ff7f50;
    }
    & > :nth-child(2) {
      background-color: #eccc68;
    }
    & > :nth-child(3) {
      background-color: rgba(255, 0, 0, 0.808);
    }
  }
  .carousel-prev,
  .carousel-next {
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    position: absolute;
    top: 50%;
    opacity: 10%;
    background-color: #000;
    color: #fff;
    border-radius: 50% 50%;
    transform: translateY(-50%);
    cursor: pointer;
    transition: all 0.2s;
    &:hover {
      opacity: 50%;
    }
  }
  .carousel-prev {
    left: 10px;
  }
  .carousel-next {
    right: 10px;
  }
  .indicator {
    display: flex;
    justify-content: space-between;
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);

    width: 60px;
    height: 10px;
    & span {
      width: 10px;
      height: 10px;
      border: 1px solid #fff;
      border-radius: 50%;
      cursor: pointer;
      &.active {
        background: #fff;
      }
    }
  }
}
</style>
